|
1
|
|
|
/** |
|
2
|
|
|
* Nextcloud - passman |
|
3
|
|
|
* |
|
4
|
|
|
* @copyright Copyright (c) 2016, Sander Brand ([email protected]) |
|
5
|
|
|
* @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected]) |
|
6
|
|
|
* @license GNU AGPL version 3 or any later version |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
11
|
|
|
* License, or (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
(function () { |
|
24
|
|
|
'use strict'; |
|
25
|
|
|
/** |
|
26
|
|
|
* @ngdoc directive |
|
27
|
|
|
* @name passmanApp.directive:passwordGen |
|
28
|
|
|
* @description |
|
29
|
|
|
* # passwordGen |
|
30
|
|
|
*/ |
|
31
|
|
|
angular.module('passmanApp') |
|
32
|
|
|
.directive('credentialCounter', [function () { |
|
33
|
|
|
return { |
|
34
|
|
|
template: '<div ng-show="counter" translate="number.filtered" translate-values="{number_filtered: counter, credential_number: total}"></div>', |
|
35
|
|
|
replace: false, |
|
36
|
|
|
restrict: 'A', |
|
37
|
|
|
scope: { |
|
38
|
|
|
credentials: '=credentialCounter', |
|
39
|
|
|
deleteTime: '=', |
|
40
|
|
|
vault: '=', |
|
41
|
|
|
filters: '=' |
|
42
|
|
|
}, |
|
43
|
|
|
|
|
44
|
|
|
link: function (scope) { |
|
45
|
|
|
function countCredentials() { |
|
46
|
|
|
var countedCredentials = 0; |
|
47
|
|
|
var total = 0; |
|
48
|
|
|
angular.forEach(scope.credentials, function (credential) { |
|
49
|
|
|
total = (credential.hidden !== 1) ? total + 1 : total; |
|
50
|
|
|
if(credential.delete_time >= scope.deleteTime && credential.hidden === 0){ |
|
51
|
|
|
countedCredentials = countedCredentials+1; |
|
52
|
|
|
} |
|
53
|
|
|
}); |
|
54
|
|
|
scope.counter = countedCredentials; |
|
55
|
|
|
scope.total = total; |
|
56
|
|
|
} |
|
57
|
|
|
scope.$watch('[credentials, deleteTime, filters]', function () { |
|
58
|
|
|
countCredentials(); |
|
59
|
|
|
}, true); |
|
60
|
|
|
} |
|
61
|
|
|
}; |
|
62
|
|
|
}]); |
|
63
|
|
|
}()); |